#include "plane.h"

plane::plane()
{

}

plane::plane(int A, int L, int T, int X, int Y)
{
    attack=A;
    life=L;
    type=T;
    x=X;
    y=Y;

}

void plane::AddBullet()
{
    if(bullet_pre>=bullet_fre)
    {
        bullet_pre=0;
        if(type==1)
        {
        }
        else if(type==2)
        {
            bullet bul(attack,2,x+25,y+35); //25和35代表子弹偏移量
            Bullets.push_back(bul);
        }
        else if(type==3)
        {
            bullet bul1(attack,2,x+25,y+115);   //115代表子弹偏移量
            bullet bul2(attack,2,x+75,y+115);
            Bullets.push_back(bul1);
            Bullets.push_back(bul2);
        }

    }
    else
        bullet_pre+=update_fre;

}

void plane::RenewPos()
{
    if(type==1 || type==2)  //小，中飞机只移动y
    {
        if(type==1)
            y+=fly_speed;
        else
            y+=fly_speed-10;
    }
    else if(type==3)   //打飞机只移动x
    {
        if(x-move_speed<=35)
            left=false;
        if(x+move_speed>=1300)
            left=true;
        if(left)
        {
            x-=move_speed;
        }
        else
            x+=move_speed;

    }
}
